package com.bio.dao.impl;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public abstract class GenricType {

	private GenricType() {
	}

	public static Class get(Class clazz, int index) {
		Type genType = clazz.getGenericSuperclass();

		if (!(genType instanceof ParameterizedType)) {
			return Object.class;
		}

		Type[] params = ((ParameterizedType) genType).getActualTypeArguments();

		
		if (index >= params.length || index < 0) {
			return Object.class;
		}
		if (!(params[index] instanceof Class)) {
			return Object.class;
		}
		
		for (int i = 0; i < params.length; i++) {
			System.out.println(i + ": " + params[i]);
		}
		
		return (Class) params[index];
	}
}
